package zyn_hy_login;

public class Mk_log
{
	public final void logToDataBase(int userid, String username, String mk_num, String msg, String Logtime)
	{
		try
		{
			String text = "insert mk_rizhi(id2,user_name,mk_num,addtime,operation) ";
			Object obj2 = text;
			DBCommon.excuteSql(String.Concat(new Object[] {obj2, "values(", userid, ",'", username, "','", mk_num, "','", Logtime, "','", msg, "')"}));
		}
		catch (RuntimeException exception)
		{
			this.logToTextFile(Mk_log_config.LogPath, exception.getMessage(), "[数据库操作失败]");
		}
	}

	public final void logToTextFile(String path, String msg, String source)
	{
		if (((path != null) && (msg != null)) && (source != null))
		{
			try
			{
				if ((new java.io.File(path)).isFile())
				{
					if ((new java.io.File(path)).length() < Mk_log_config.LogMaxSize)
					{
						this.WriteToFile(path, msg, source);
					}
				}
				else
				{
					this.WriteToFile(path, msg, source);
				}
			}
			catch (RuntimeException exception)
			{
				System.out.println("写入文件时出现异常: " + exception);
			}
		}
	}

	private void WriteToFile(String path, String msg, String source)
	{
		StreamWriter writer = new StreamWriter(path, true);
		writer.Write(source + msg);
		writer.Close();
	}
}